﻿#include "smallwidget.h"
#include "ui_smallwidget.h"

smallWidget::smallWidget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::smallWidget)
{
    ui->setupUi(this);

    // QSpinBox移动 QSlider跟着移动
    // 通过函数指针获取
    void (QSpinBox::* spsign)(int)=&QSpinBox::valueChanged;
    connect(ui->spinBox,spsign,ui->horizontalSlider,&QSlider::setValue);

    // QSlider移动 QSpinBox跟着移动
    connect(ui->horizontalSlider,&QSlider::valueChanged,ui->spinBox,&QSpinBox::setValue);

}

smallWidget::~smallWidget()
{
    delete ui;
}

void smallWidget::setNum(int num)
{
    ui->spinBox->setValue(num);
}

int smallWidget::getNum()
{
    return ui->spinBox->value();
}
